//
//  SendHttpOperation.m
//  FinancialConsultant
//
//  Created by liyun on 12-11-1.
//  Copyright (c) 2012年 liyun. All rights reserved.
//

#import "SendHttpOperation.h"

static SendHttpOperation *instance = nil;

@implementation SendHttpOperation

@synthesize loginDelegate,getInformationDelegate,getUserInfoDelegate,getWebInfoListDelegate,getAttackInfoDelegate,getOfficalMailDelegate,getNoReadCountDelegate,sendMailDelegate,addDraftMailDelegate,getUserListDelegate,setMailReadDelegate,getStudyGardeDelegate,delDraftMailDelegate,deleteMailInFlagDelegate;

/************************************************************************************************
 函数名称 : + (SendHttpOperation *)shareSendHttpOperation
 函数描述 : 创建单例，在其他文件中可以直接类名加方法调用该类中方法
 输入参数 : 无
 返回    : 无
 备注    : 无
 ************************************************************************************************/
+ (SendHttpOperation *)shareSendHttpOperation
{
    if(!instance)
    {
        instance = [[SendHttpOperation alloc] init];
    }
    return instance;
}

/************************************************************************************************
 函数描述 : 登录判断
 ************************************************************************************************/
- (void)login:(NSString *)cmdStr
        Useid:(NSString *)userid
          Pwd:(NSString *)pwd
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/user/login.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"userid":userid,@"pwd":pwd} forKey:@"params"];
   [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"login-->%@",result);
        [loginDelegate passLogin:result];
       
       
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 获取用户信息
 ************************************************************************************************/
- (void)getUserInfo:(NSString *)cmdStr
              Useid:(NSString *)userid
                Pwd:(NSString *)pwd
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/user/GetUserInfo.ashx",base_url];
    
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"userid":userid,@"pwd":pwd} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"getUserInfo--%@",result);
        [getUserInfoDelegate passgetUserInfo:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
        
    }];
}

/************************************************************************************************
 函数描述 : 获取公告列表
 ************************************************************************************************/
- (void)GetWebInfoList:(NSString *)cmdStr
                   Cur:(NSString *)cur
                  Rows:(NSString *)rows
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/WebInfo/GetWebInfoList.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"cur":cur,@"rows":rows} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        responseStr = [responseStr  stringByReplacingOccurrencesOfString:@"\r\n" withString:@"^^^"];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        
        [getWebInfoListDelegate passGetWebInfoList:result];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 获取公告详情
 ************************************************************************************************/
- (void)GetInformation:(NSString *)cmdStr
              infoGuid:(NSString *)infoGuid
{
    
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/WebInfo/GetInformation.ashx",base_url];
    
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"infoGuid":infoGuid} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"%@",result);
        
        [getInformationDelegate passGetInformation:result];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
    
}

/************************************************************************************************
 函数描述 : 获取公告附件信息
 ************************************************************************************************/
- (void)GetAttachInfo:(NSString *)cmdStr
           CliengGuid:(NSString *)guidStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/Attach/GetAttachInfo.ashx",base_url];
    
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"cliengGuid":guidStr} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"GetAttachInfo-->%@",result);
        
        [getAttackInfoDelegate passGetAttackInfo:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
    
}

/************************************************************************************************
 函数描述 : 获取邮件列表
 ************************************************************************************************/
- (void)GetMailList:(NSString *)cmdStr//获取邮箱列表
                Cur:(NSString *)cur
               Rows:(NSString *)rows
        BoxTypeGuid:(NSString *)typeStr
           haveread:(NSString *)hasread
      ownerUserGuid:(NSString *)userGuid
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/API/Mail/GetMailList.ashx",base_url];
    
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"cur":cur,@"rows":rows,@"boxTypeGuid":typeStr,@"haveread":hasread,@"ownerUserGuid":userGuid} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        responseStr = [responseStr  stringByReplacingOccurrencesOfString:@"\n" withString:@"{^^^}"];
        responseStr = [responseStr  stringByReplacingOccurrencesOfString:@"\r" withString:@"{###}"];
//        responseStr = [responseStr  stringByReplacingOccurrencesOfString:@"\n" withString:@"^^^"];
        NSLog(@"responseStr-->%@",responseStr);
        
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"GetMailList-->%@",result);
        if([typeStr isEqualToString:@"100002"])
        {
//            NSLog(@"GetMailList-->%@",result);
        }
        [getOfficalMailDelegate passOfficalMail:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 获取未读邮件数量
 ************************************************************************************************/
- (void)GetNoReadCount:(NSString *)cmdStr
           BoxTypeGuid:(NSString *)boxTypeGuidStr
         ownerUserGuid:(NSString *)ownerUserGuidStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/Mail/GetNoReadCount.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"boxTypeGuid":boxTypeGuidStr,@"ownerUserGuid":ownerUserGuidStr} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"%@",result);
        [getNoReadCountDelegate passNoReadCount:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 发送邮件
 ************************************************************************************************/
- (void)SendMail:(NSString *)cmdStr
        mailGuid:(NSString *)mailGuidStr
    fromUserGuid:(NSString *)fromUserGuidStr
    fromDispName:(NSString *)fromDispNameStrv
  toUserGuidList:(NSString *)toUserGuidListStr
toUserDispNameList:(NSString *)toUserDispNameListStr
         subject:(NSString *)subjectStr
     mailContent:(NSString *)mailContentStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/Mail/SendMail.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"mailGuid":mailGuidStr,@"fromUserGuid":fromUserGuidStr,@"fromDispName":fromDispNameStrv,@"toUserGuidList":toUserGuidListStr,@"toUserDispNameList":toUserDispNameListStr,@"secretUserGuidList":@"",@"secretUserDispNameList":@"",@"chaoSongUserGuidList":@"",@"chaoSongUserDispNameList":@"",@"subject":subjectStr,@"mailContent":mailContentStr,@"hasAttach":@"0",@"isAllSign":@"0",@"importance":@"0",@"haveread":@"0",@"mailLength":@"0"} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"SendMail-->%@",result);
        [sendMailDelegate passSendMail:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 将邮件添加到草稿箱
 ************************************************************************************************/
- (void)AddDraftMail:(NSString *)cmdStr
            mailGuid:(NSString *)mailGuidStr
        fromUserGuid:(NSString *)fromUserGuidStr
        fromDispName:(NSString *)fromDispNameStrv
      toUserGuidList:(NSString *)toUserGuidListStr
  toUserDispNameList:(NSString *)toUserDispNameListStr
             subject:(NSString *)subjectStr
         mailContent:(NSString *)mailContentStr
    originalMailGuid:(NSString *)originalMailGuidStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/Mail/AddDraftMail.ashx",base_url];
    
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"mailGuid":mailGuidStr.length==0?@"":mailGuidStr,@"fromUserGuid":fromUserGuidStr.length==0?@"":fromUserGuidStr,@"fromDispName":fromDispNameStrv.length==0?@"":fromDispNameStrv,@"toUserGuidList":toUserGuidListStr.length==0?@"":toUserGuidListStr,@"toUserDispNameList":toUserDispNameListStr.length==0?@"":toUserDispNameListStr,@"secretUserGuidList":@"",@"secretUserDispNameList":@"",@"chaoSongUserGuidList":@"",@"chaoSongUserDispNameList":@"",@"subject":subjectStr,@"mailContent":mailContentStr.length==0?@"":mailContentStr,@"hasAttach":@"0",@"isAllSign":@"0",@"importance":@"0",@"haveread":@"0",@"mailLength":@"0",@"originalMailGuid":originalMailGuidStr} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"AddDraftMail-->%@",result);
        [addDraftMailDelegate passAddDraftMail:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 删除草稿箱邮件
 ************************************************************************************************/
- (void)delDraftMail:(NSString *)cmdStr
            mailGuid:(NSString *)mailGuidStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/Mail/DelDraftMail.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"mailGuid":mailGuidStr} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"%@",result);
        [delDraftMailDelegate passdelDraftMail:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 删除邮件
 ************************************************************************************************/
- (void)deleteMailInFlag:(NSString *)cmdStr
                mailGuid:(NSString *)mailGuidStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/Mail/DeleteMailInFlag.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"mailGuid":mailGuidStr} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"%@",result);
        [deleteMailInFlagDelegate passDeleteMailInFlag:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}


/************************************************************************************************
 函数描述 : 获取用户联系人
 ************************************************************************************************/
- (void)GetUserList:(NSString *)cmdStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/user/getuserlist.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"GetUserList-->%@",result);
        [getUserListDelegate passGetUserList:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 设置邮件已读
 ************************************************************************************************/
- (void)SetMailRead:(NSString *)cmdStr
           mailGuid:(NSString *)mailGuidStr
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/Mail/SetMailRead.ashx",base_url];    
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"mailGuid":mailGuidStr} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"SetMailRead-->%@",result);
//        [setMailReadDelegate passSetMailRead:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}

/************************************************************************************************
 函数描述 : 学习园地
 ************************************************************************************************/
- (void)studyGarde:(NSString *)cmdStr
               Cur:(NSString *)cur
              Rows:(NSString *)rows
{
    NSString *pathStr = [NSString stringWithFormat:@"%@:88/api/WebInfo/GetWebInfoListBy010.ashx",base_url];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];//这里要将url设置为空
    httpClient.parameterEncoding = AFJSONParameterEncoding;
    [httpClient setDefaultHeader:@"Accept" value:@"text/json"];
    
    NSMutableDictionary *params=[[NSMutableDictionary alloc] init];   // 要传递的json数据是一个字典
    
    [params setObject:cmdStr forKey:@"cmd"];
    [params setObject:USERNAME forKey:@"username"];
    [params setObject:PASSWORD forKey:@"password"];
    [params setObject:@{@"cur":cur,@"rows":rows} forKey:@"params"];
    
    [httpClient postPath:pathStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@"data====%@",params);
        
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *result = [NSDictionary dictionaryWithDictionary:responseStr.JSONValue];
        NSLog(@"GetWebInfoListBy010-->%@",result);
        [getStudyGardeDelegate passGetStudyGarde:result];
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"[HTTPClient Error]: %@", error);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"REMOVE" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"TIP" object:@{@"msg":@"网络获取数据失败，请重新尝试！"}];
    }];
}


/************************************************************************************************
 函数描述 : 登录2
 ************************************************************************************************/
- (NSDictionary *)login_do:(NSString *)userName
                  passWord:(NSString *)password
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/login.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request setPostValue:password forKey:@"password"];
    [request startSynchronous];
    NSLog(@"--->%@-->%@",userName,password);
    NSLog(@"%@",[request responseString]);
    NSError* error = nil;
    if (error != nil)
    {
        NSLog(@"error");
    }
    return [[request responseString] JSONValue];
}

/************************************************************************************************
 函数描述 : 待办事宜
 ************************************************************************************************/
- (NSDictionary *)WaitHandleBanli:(NSString *)userName
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/WaitHandle_NeedHandle_Banli.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request startSynchronous];
    
    NSLog(@"usename-->%@",userName);
    NSLog(@"22-->%@",[request responseString]);
    NSError* error = nil;
//    DDXMLDocument* document = [[DDXMLDocument alloc] initWithXMLString:[request responseString] options:0 error:&error];
    if (error != nil)
    {
        NSLog(@"error");
    }
    return [[request responseString] JSONValue];
}

/************************************************************************************************
 函数描述 : 待办事宜展示
 ************************************************************************************************/
- (NSDictionary *)Handle_Main:(NSString *)userName
   ProcessVersionInstanceGuid:(NSString *)processVersionInstanceGuid
                 WorkItemGuid:(NSString *)workItemGuid
              MessageItemGuid:(NSString *)messageItemGuid
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/Handle_Main.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request setPostValue:processVersionInstanceGuid forKey:@"ProcessVersionInstanceGuid"];
    [request setPostValue:workItemGuid forKey:@"WorkItemGuid"];
    [request setPostValue:messageItemGuid forKey:@"MessageItemGuid"];
    [request startSynchronous];
    NSLog(@"Handle_Main-->%@",[request responseString]);
    NSError* error = nil;
    if (error != nil)
    {
        NSLog(@"error");
    }
    return [[request responseString] JSONValue];
}

/************************************************************************************************
 函数描述 : 获取事项处理页接口
 ************************************************************************************************/
- (NSDictionary *)CommonOperationHandlePass_SingleTransition_Page:(NSString *)userName
                                                     WorkItemGuid:(NSString *)workItemGuidStr
                                                    OperationGuid:(NSString *)operationGuidStr
                                                   TransitionGuid:(NSString *)transitionGuidStr
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/CommonOperationHandlePass_SingleTransition_Page.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request setPostValue:workItemGuidStr forKey:@"WorkItemGuid"];
    [request setPostValue:operationGuidStr forKey:@"OperationGuid"];
    [request setPostValue:transitionGuidStr forKey:@"TransitionGuid"];
    [request startSynchronous];
    NSLog(@"CommonOperationHandlePass_SingleTransition_Page-->%@",[request responseString]);
    NSError* error = nil;
    //    DDXMLDocument* document = [[DDXMLDocument alloc] initWithXMLString:[request responseString] options:0 error:&error];
    if (error != nil)
    {
        NSLog(@"error");
    }
    return [[request responseString] JSONValue];
}

/************************************************************************************************
 函数描述 : 事项处理接口
 ************************************************************************************************/
- (NSDictionary *)CommonOperationHandlePass_SingleTransition:(NSString *)userName
                                                WorkItemGuid:(NSString *)workItemGuidStr
                                               OperationGuid:(NSString *)operationGuidStr
                                              TransitionGuid:(NSString *)transitionGuidStr
                                                userGuidList:(NSString *)userGuidListStr
                                                userNameList:(NSString *)userNameListStr
                                                     opinion:(NSString *)opinionStr
                                                       toSel:(NSString *)toSelStr
                                              nextTransition:(NSString *)nextTransitionStr
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/CommonOperationHandlePass_SingleTransition.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request setPostValue:workItemGuidStr forKey:@"WorkItemGuid"];
    [request setPostValue:operationGuidStr forKey:@"OperationGuid"];
    [request setPostValue:transitionGuidStr forKey:@"TransitionGuid"];
    [request setPostValue:userGuidListStr forKey:@"userGuidList"];
    [request setPostValue:userNameListStr forKey:@"userNameList"];
    [request setPostValue:opinionStr forKey:@"opinion"];
    [request setPostValue:toSelStr forKey:@"toSel"];
    [request setPostValue:nextTransitionStr forKey:@"nextTransition"];
    [request startSynchronous];
    NSLog(@"CommonOperationHandlePass_SingleTransition-->%@",[request responseString]);
    NSError* error = nil;
    //    DDXMLDocument* document = [[DDXMLDocument alloc] initWithXMLString:[request responseString] options:0 error:&error];
    if (error != nil)
    {
        NSLog(@"error");
    }
    return [[request responseString] JSONValue];
}


/************************************************************************************************
 函数描述 : 待收公文列表
 ************************************************************************************************/
- (NSMutableArray *)ArchiveList_ToReceive:(NSString *)userName
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/ArchiveList_ToReceive.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request startSynchronous];
//    NSLog(@"ArchiveList_ToReceive-->%@",[request responseString]);
    
    NSDictionary *dic = [[NSDictionary alloc] initWithDictionary:[[request responseString] JSONValue]];

    NSRange range1 = [[dic objectForKey:@"msg"] rangeOfString:@"<table class=\"GridView\""];
    NSString *tempStr1 = [[dic objectForKey:@"msg"] substringFromIndex:range1.location];
    NSRange range2 = [tempStr1 rangeOfString:@"</table>"];
    
    NSString *tempStr2 = [tempStr1 substringToIndex:range2.location+range2.length];
    DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:tempStr2 options:0 error:nil];
	NSArray *items = [doc nodesForXPath:@"/table/tr/td" error:nil];
    NSMutableArray *eleDicArr = [[NSMutableArray alloc] init];

    for (int i = 1; i<items.count/7; i++)
    {
        NSMutableDictionary *tempDic = [[NSMutableDictionary alloc] init];
        
        for (int j = 7*i; j< 7*i+7; j++)
        {
            if(j%7 == 2)
            {
                NSArray *items = [doc nodesForXPath:@"/table/tr/td/a" error:nil];
                if(items.count != 0)
                {
                    DDXMLElement *obj_title = [items objectAtIndex:(i-1)*2];
                    
                    NSString *str = [obj_title.stringValue stringByReplacingOccurrencesOfString:@" " withString:@""];
                    [tempDic setObject:str forKey:@"title"];
                    
                    NSString *titleStr =[NSString stringWithFormat:@"%@",obj_title];
                    NSRange range11 = [titleStr rangeOfString:@"('"];
                    NSString *tempStr11 = [titleStr substringFromIndex:range11.location+range11.length];
                    NSRange range22 = [tempStr11 rangeOfString:@"')"];
                    NSString *tempStr22 = [tempStr11 substringToIndex:range22.location+range22.length];
                    NSLog(@"tempStr2--->%@",tempStr22);
                    
                    NSRange timeRange = [tempStr22 rangeOfString:@"','"];
                    NSString *sendTimeStr = [tempStr22 substringToIndex:timeRange.location];
                    NSLog(@"sendTimeStr--->%@",sendTimeStr);
                    
                    NSRange sysGuidrange;
                    sysGuidrange.location = timeRange.location+3;
                    sysGuidrange.length = 36;
                    NSString *sysGuidStr = [tempStr22 substringWithRange:sysGuidrange];
                    NSLog(@"sysGuidStr--->%@",sysGuidStr);
                    
                    NSRange ouCertGuidrange;
                    ouCertGuidrange.location = sysGuidrange.location+39;
                    ouCertGuidrange.length = 36;
                    NSString *ouCertGuidStr = [tempStr22 substringWithRange:ouCertGuidrange];
                    NSLog(@"OuCertGuid--->%@",ouCertGuidStr);
                    
                    [tempDic setObject:str.length==0?@"":str forKey:@"title"];
                    [tempDic setObject:sendTimeStr.length==0?@"":sendTimeStr forKey:@"sendTime"];
                    [tempDic setObject:sysGuidStr.length==0?@"":sysGuidStr forKey:@"SysGuid"];
                    [tempDic setObject:ouCertGuidStr.length==0?@"":ouCertGuidStr forKey:@"OuCertGuid"];
                    
                }
                else
                {
                    [tempDic setObject:@"" forKey:@"title"];
                    [tempDic setObject:@"" forKey:@"sendTime"];
                    [tempDic setObject:@"" forKey:@"SysGuid"];
                    [tempDic setObject:@"" forKey:@"OuCertGuid"];
                }
            }
        }
        [eleDicArr addObject:tempDic];
    }
    return eleDicArr;
}

/************************************************************************************************
 函数描述 : 获取待签收公文内容接口
 ************************************************************************************************/
- (NSDictionary *)Archive_Sign_Page:(NSString *)userName
                           sendTime:(NSString *)sendTimeStr
                            SysGuid:(NSString *)sysGuidStr
                           FileType:(NSString *)fileTypeStr
                         OuCertGuid:(NSString *)ouCertGuidStr
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/Archive_Sign_Page.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request setPostValue:sendTimeStr forKey:@"sendTime"];
    [request setPostValue:sysGuidStr forKey:@"SysGuid"];
    [request setPostValue:fileTypeStr forKey:@"FileType"];
    [request setPostValue:ouCertGuidStr forKey:@"OuCertGuid"];
    [request startSynchronous];
    
    NSDictionary *dic = [[NSDictionary alloc] initWithDictionary:[[request responseString] JSONValue]];
    NSLog(@"thisiiii======%@",[dic objectForKey:@"msg"]);
    NSRange range1 = [[dic objectForKey:@"msg"] rangeOfString:@"<table   width=\"100%\"   border=\"0\">"];
    NSString *tempStr1 = [[dic objectForKey:@"msg"] substringFromIndex:range1.location];
    NSRange range2 = [tempStr1 rangeOfString:@"</table>"];
    NSString *tempStr2 = [tempStr1 substringToIndex:range2.location+range2.length];
//    NSLog(@"tempStr2--->%@",tempStr2);
    DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:tempStr2 options:0 error:nil];
    
    NSArray *items1 = [doc nodesForXPath:@"/table/tr/td" error:nil];
    
    NSMutableDictionary *docuDic = [[NSMutableDictionary alloc] init];
    
    [docuDic setObject:[dic objectForKey:@"errcode"] forKey:@"errcode"];
    
    for (int i = 0; i< items1.count; i++)
    {
        switch (i)
        {
            case 0:
            {
//                NSString *fawenhao = [[items1 objectAtIndex:1] stringValue];
//                [docuDic setObject:fawenhao.length==0?@"":fawenhao forKey:@"fawenhao"];
            }
                break;
            case 2:
            {
                NSString *simiStr = [NSString stringWithFormat:@"%@",[items1 objectAtIndex:3]];
                DDXMLDocument *simiDoc = [[DDXMLDocument alloc] initWithXMLString:simiStr options:0 error:nil];
                NSArray *simiItem = [simiDoc nodesForXPath:@"/td/select/option" error:nil];
                
                NSMutableArray *simiTemp = [[NSMutableArray alloc] init];
                for (int i  = 0; i<simiItem.count; i++)
                    [simiTemp addObject:[[simiItem objectAtIndex:i] stringValue]];
                [docuDic setObject:simiTemp forKey:@"simidengji"];
                
            }
                break;
            case 4:
            {
                NSString *baomiStr = [NSString stringWithFormat:@"%@",[items1 objectAtIndex:5]];
                DDXMLDocument *baomiDoc = [[DDXMLDocument alloc] initWithXMLString:baomiStr options:0 error:nil];
                NSArray *baomiItem = [baomiDoc nodesForXPath:@"/td/select/option" error:nil];
                
                NSMutableArray *baomiTemp = [[NSMutableArray alloc] init];
                for (int i  = 0; i<baomiItem.count; i++)
                    [baomiTemp addObject:[[baomiItem objectAtIndex:i] stringValue]];
                [docuDic setObject:baomiTemp forKey:@"baomiqixian"];
            }
                break;
            case 6:
            {
                NSString *jinjiStr = [NSString stringWithFormat:@"%@",[items1 objectAtIndex:7]];
                DDXMLDocument *jinjiDoc = [[DDXMLDocument alloc] initWithXMLString:jinjiStr options:0 error:nil];
                NSArray *jinjiItem = [jinjiDoc nodesForXPath:@"/td/select/option" error:nil];
                
                NSMutableArray *jinjiTemp = [[NSMutableArray alloc] init];
                for (int i  = 0; i<jinjiItem.count; i++)
                    [jinjiTemp addObject:[[jinjiItem objectAtIndex:i] stringValue]];
                [docuDic setObject:jinjiTemp forKey:@"jinjichengdu"];
            }
                break;
            default:
                break;
        }
    }
    
    NSArray *key = [[NSArray alloc] initWithObjects:@"zhusongjiguan",@"chaosongjiguan",@"zhubanjiguan",@"xiebanjiguan",@"zhutici",@"gongwenbiaoti",@"fawenbumen",@"shouwenbumen",@"gongwenbeizhu",@"fawenshijian",@"yinfafenshu",@"gongwenzhengwen",@"gongwenfujian",@"fawenhao", nil];
    
    
    
    NSArray *key2 = [[NSArray alloc] initWithObjects:@"<input name=\"ctl00$ContentPlaceHolder1$txtMainGive\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtSubGive\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtMainDo\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtSubDo\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtTopic\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtTitle\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtSendDeptName\"",@"<textarea name=\"ctl00$ContentPlaceHolder1$txtInceptDeptName\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtNote\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtSendDate\"",@"<input name=\"ctl00$ContentPlaceHolder1$txtCopyNum\"",@"<span id=\"ctl00_ContentPlaceHolder1_lblArchiveLink\">",@"<span id=\"ctl00_ContentPlaceHolder1_lblAttLink\">",@"<input name=\"ctl00$ContentPlaceHolder1$txtArchiveID_Send\"", nil];
    
    
    NSRange range12 = [[dic objectForKey:@"msg"] rangeOfString:@"<td class=\"TableSpecial1\" align=\"right\" width=\"15%\">"];
    NSString *tempStr12 = [[dic objectForKey:@"msg"] substringFromIndex:range12.location];
    NSRange range22 = [tempStr12 rangeOfString:@"</table>"];
    NSString *tempStr22 = [tempStr12 substringToIndex:range22.location];
    tempStr22 = [NSString stringWithFormat:@"<tr>%@",tempStr22];
    tempStr22 = [tempStr22  stringByReplacingOccurrencesOfString:@"\r\n" withString:@""];
    tempStr22 = [tempStr22  stringByReplacingOccurrencesOfString:@"nowrap" withString:@""];
    
        
    NSRange range111 = [[dic objectForKey:@"msg"] rangeOfString:@"<span id=\"ctl00_ContentPlaceHolder1_lblArchiveLink\">"];
    NSString *tempStr111 = [[dic objectForKey:@"msg"] substringFromIndex:range111.location];
    NSRange range222 = [tempStr111 rangeOfString:@"/span>"];
    NSString *tempStr222 = [tempStr111 substringToIndex:range222.location];
    
    NSRange range1111 = [tempStr222 rangeOfString:@">"];
//    NSLog(@"range1111--->%ld",range1111.location);
    if(range1111.location < 1000)
    {
        NSString *tempStr1111 = [tempStr222 substringFromIndex:range1111.location+range1111.length];
        NSRange range2222 = [tempStr1111 rangeOfString:@"</a>"];
        if(range2222.location <1000)
        {
            NSString *tempStr2222 = [tempStr1111 substringToIndex:range2222.location];
    //        NSLog(@"tempStr2222---000--->%@",tempStr2222);
            
            NSRange range111zhengwen = [tempStr2222 rangeOfString:@">"];
            if(range111zhengwen.location <1000)
            {
                NSString *tempStr111zhengwen = [tempStr2222 substringFromIndex:range111zhengwen.location+range111zhengwen.length];
    //            NSLog(@"tempStr111zhengwen-->%@",tempStr111zhengwen);
                [docuDic setObject:tempStr111zhengwen.length!=0?tempStr111zhengwen:@"" forKey:@"gongwenzhengwen"];
            }
            else
               [docuDic setObject:@"" forKey:@"gongwenzhengwen"];
        }
    }
    else
        [docuDic setObject:@"" forKey:@"gongwenzhengwen"];
    
    NSRange range111fujian = [tempStr222 rangeOfString:@"href='"];
    if(range111fujian.location<1000)
    {
        NSString *tempStr111fujian = [tempStr222 substringFromIndex:range111fujian.location+range111fujian.length];
        tempStr111fujian = [tempStr111fujian stringByReplacingOccurrencesOfString:@"\"" withString:@""];
        NSRange range222fujian = [tempStr111fujian rangeOfString:@"'>"];
        if(range222fujian.location < 1000)
        {
            NSString *tempStr222fujian = [tempStr111fujian substringToIndex:range222fujian.location];
            NSLog(@"url--->%@",tempStr222fujian);
            [docuDic setObject:tempStr222fujian.length!=0?tempStr222fujian:@"" forKey:@"url"];
        }
        else
        {
            [docuDic setObject:@"" forKey:@"url"];
        }
    }
    
    
    for (int i = 0; i< 14; i++)
    {
        if(i != 11 && i != 12)
        {
            NSRange range111 = [[dic objectForKey:@"msg"] rangeOfString:[key2 objectAtIndex:i]];
            NSString *tempStr111 = [[dic objectForKey:@"msg"] substringFromIndex:range111.location];
            NSRange range222 = [tempStr111 rangeOfString:@"</td>"];
            NSString *tempStr222 = [tempStr111 substringToIndex:range222.location];

            NSLog(@"eeerrr-->%@",tempStr222);
            
            NSRange range1111 = [tempStr222 rangeOfString:@"value=\""];
            NSLog(@"range1111--->%ld",range1111.location);
            if(range1111.location < 1000)
            {
                NSString *tempStr1111 = [tempStr222 substringFromIndex:range1111.location+range1111.length];
                NSRange range2222 = [tempStr1111 rangeOfString:@"\""];
                
                NSString *tempStr2222 = [tempStr1111 substringToIndex:range2222.location];
                
                NSLog(@"tempStr2222--->%@",tempStr2222);
                [docuDic setObject:tempStr2222.length!=0?tempStr2222:@"" forKey:[key objectAtIndex:i]];
            }
            else
            {
                [docuDic setObject:@"" forKey:[key objectAtIndex:i]];
            }
        }
        
    }
    
    
    NSRange range111file = [[dic objectForKey:@"msg"] rangeOfString:@"<select name=\"ctl00$ContentPlaceHolder2$jpdFileType"];
    NSString *tempStr111file = [[dic objectForKey:@"msg"] substringFromIndex:range111file.location];
    NSLog(@"tempStr113331file-->%@",tempStr111file);
    NSRange range222file = [tempStr111file rangeOfString:@"</select>"];
    if(range222file.location<1000)
    {
        NSString *tempStr222file = [tempStr111file substringToIndex:range222file.location+range222file.length];
        NSLog(@"tempStr222file-->%@",tempStr222file);
        NSRange range1111file = [tempStr222file rangeOfString:@"<option value=\""];
        if(range1111file.location < 1000)
        {
            NSString *tempStr1111 = [tempStr222file substringFromIndex:range1111file.location+range1111file.length];
            NSRange range2222 = [tempStr1111 rangeOfString:@"\">"];
            NSString *tempStr2222 = [tempStr1111 substringToIndex:range2222.location];
            
            NSLog(@"tempStr2222--->%@",tempStr2222);
            [docuDic setObject:tempStr2222.length!=0?tempStr2222:@"" forKey:@"jpdFileType"];
        }
        else
            [docuDic setObject:@"" forKey:@"jpdFileType"];
    }
    
    return docuDic;
}


/************************************************************************************************
 函数描述 : 签收公文接口
 ************************************************************************************************/
- (NSDictionary *)Archive_Sign:(NSString *)userName
                      sendTime:(NSString *)sendTimeStr
                       SysGuid:(NSString *)sysGuidStr
                      FileType:(NSString *)fileTypeStr
                    OuCertGuid:(NSString *)ouCertGuidStr
                   jpdFileType:(NSString *)jpdFileTypeStr
                       jpdMiji:(NSString *)jpdMijiStr
                    jpdBaoMiQx:(NSString *)jpdBaoMiQxStr
                      jpdJinji:(NSString *)jpdJinjiStr
{
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@:8080/agent/Archive_Sign.do",base_url]];
    ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:userName forKey:@"username"];
    [request setPostValue:sendTimeStr forKey:@"sendTime"];
    [request setPostValue:sysGuidStr forKey:@"SysGuid"];
    [request setPostValue:fileTypeStr forKey:@"FileType"];
    [request setPostValue:ouCertGuidStr forKey:@"OuCertGuid"];
    [request setPostValue:jpdFileTypeStr forKey:@"jpdFileType"];
    [request setPostValue:jpdMijiStr forKey:@"jpdMiji"];
    [request setPostValue:jpdBaoMiQxStr forKey:@"jpdBaoMiQx"];
    [request setPostValue:jpdJinjiStr forKey:@"jpdJinji"];
    [request startSynchronous];
    NSLog(@"Archive_Sign-->%@",[request responseString]);
    NSError* error = nil;

    if (error != nil)
    {
        NSLog(@"error");
    }
    return [[request responseString] JSONValue];
}



@end
